<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script src="/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>

    <![endif]-->
    <script>
        function displayDate(){
            document.getElementById("demo").innerHTML=Date();
        }
    </script>
    <style>
        .layui-card-header ul li{
            float: left;
            margin: 10px;
        }
        .layui-card-header ul li img{
            width: 280px;
            height: 200px;
        }

    </style>
</head>
<body>
<div id="app" class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <blockquote class="layui-elem-quote">欢迎管理员：
                        <span class="x-red" th:text="${session.username}"></span>！当前时间:
                        <p id="demo">此处更新时间</p>

                        <button type="button" onclick="displayDate()">更新</button>
                    </blockquote>
                </div>
            </div>
        </div>
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">入住状况</div>
                <div class="layui-card-body ">
                    <ul class="layui-row layui-col-space10 layui-this x-admin-carousel x-admin-backlog">
                        <li class="layui-col-md2 layui-col-xs6">
                            <a href="javascript:;" class="x-admin-backlog-body">
                                <h3>历史注册顾客人数</h3>
                                <p><cite>{{count}}</cite></p>
                            </a>
                        </li>
                        <li class="layui-col-md2 layui-col-xs6">
                            <a href="javascript:;" class="x-admin-backlog-body">
                                <h3>总营业额</h3>
                                <p><cite>{{count2}}</cite></p></a></li>
                        <li class="layui-col-md2 layui-col-xs6">
                            <a href="javascript:;" class="x-admin-backlog-body">
                                <h3>房间类型总数</h3>
                                <p><cite>{{count3}}</cite></p></a></li>
                        <li class="layui-col-md2 layui-col-xs6">
                            <a href="javascript:;" class="x-admin-backlog-body">
                                <h3>总房间数</h3>
                                <p>
                                    <cite>{{count1}}</cite></p>
                            </a>
                        </li>
                        <li class="layui-col-md2 layui-col-xs6 ">
                            <a href="javascript:;" class="x-admin-backlog-body">
                                <h3>目前已入住人数</h3>
                                <p>
                                    <cite>{{count4}}</cite></p>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>

        <!--        <style id="welcome_style"></style>-->
    </div>
</div>
</div>

<div class="layui-card-header">
    <p>本周热门房间Top Two：</p>
    <div class="img" style="float: left">
        <ul style="list-style: none;float: left">
            <button type="button" class="layui-btn-primary" onclick="alert('本月热门房间第一名')"><img src="images/1547863202049.jpg"></button>
            <!--            <button onclick="alert('本月热门房间第一名')"><img src="images/1547863202049.jpg"></button>-->
            <button type="button" class="layui-btn-primary" onclick="alert('本月热门房间第二名')"><img src="images/1547863315754.jpg"></button>
            <!--            <button onclick="alert('本月热门房间第二名')"><img src="images/1547863315754.jpg"></button>-->
        </ul>
    </div>
</div>


<!-- import Vue before Element -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- import JavaScript -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<!-- import axios -->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    var app = new Vue({
            el: '#app',
            data: {
                count:50,
                count1:100,
                count2:88,
                count3:88,
                count4:48
            },
            methods: {

            },

            // 生命周期函数created:在vue实例加载完成后，发送ajax请求，用返回的数据填充页面
            created: function () {
                // 发送ajax数据获取管理员列表数据
                let self = this;//因为在axios里面访问this是window对象，我们先将vue实例保存在self变量里面
                axios.get('http://localhost:8080/Admin/getCustCount')
                    .then(function (response) {

                        self.count = response.data;//通过self间接访问vue实例

                        console.log("数据库中的总入住房间数为：" + self.count);
                    })
                    .catch(function (error) {
                        // handle error
                        console.log(error);
                    })
                    .finally(function () {
                        // always executed
                    });
                axios.get('http://localhost:8080/admin/roomCount')
                    .then(function (response) {

                        self.count1 = response.data;//通过self间接访问vue实例

                        console.log("数据库中的房间类型为：" + self.count1);
                    })
                    .catch(function (error) {
                        // handle error
                        console.log(error);
                    })
                    .finally(function () {
                        // always executed
                    });
                axios.get('http://localhost:8080/Admin-billcount')
                    .then(function (response) {

                        self.count2 = response.data;//通过self间接访问vue实例

                        console.log("数据库中总营业额为：" + self.count2);
                    })
                    .catch(function (error) {
                        // handle error
                        console.log(error);
                    })
                    .finally(function () {
                        // always executed
                    });
                axios.get('http://localhost:8080/admin/roomcount')
                    .then(function (response) {

                        self.count3 = response.data;//通过self间接访问vue实例

                        console.log("数据库中的总房间数为：" + self.count3);
                    })
                    .catch(function (error) {
                        // handle error
                        console.log(error);
                    })
                    .finally(function () {
                        // always executed
                    });
                axios.get('http://localhost:8080/Admin/getlivingCount')
                    .then(function (response) {

                        self.count4 = response.data;//通过self间接访问vue实例

                        console.log("数据库中目前入住人数为：" + self.count4);
                    })
                    .catch(function (error) {
                        // handle error
                        console.log(error);
                    })
                    .finally(function () {
                        // always executed
                    });
            }
        }
    );
</script>
</body>
</html>